package de.revdev.llt.bean.entities;

import de.revdev.llt.bean.entities.interfaces.EntityInterface;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author f.lindermaier
 */
@Entity
@Table(name = "tbl_participants")
public class Participants implements Serializable, EntityInterface {

    public enum ClassRoomRole {

        ADMIN, WRITER, READER
    };
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @ManyToOne
    @JoinColumn(name = "id_user")
    private User user;
    @ManyToOne
    @JoinColumn(name = "id_publicClassRoom")
    private PublicClassRoom publicClassRoom;
    @NotNull
    @Enumerated(EnumType.STRING)
    private ClassRoomRole classRoomRole;
    @NotNull
    private boolean accepted;

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public PublicClassRoom getPublicClassRoom() {
        return publicClassRoom;
    }

    public void setPublicClassRoom(PublicClassRoom publicClassRoom) {
        this.publicClassRoom = publicClassRoom;
    }

    public ClassRoomRole getClassRoomRole() {
        return classRoomRole;
    }

    public void setClassRoomRole(ClassRoomRole classRoomRole) {
        this.classRoomRole = classRoomRole;
    }

    public boolean isAccepted() {
        return accepted;
    }

    public void setAccepted(boolean accepted) {
        this.accepted = accepted;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Participants)) {
            return false;
        }
        Participants other = (Participants) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.revdev.llt.bean.entities.Participants[ id=" + id + " ]";
    }
}
